import 'package:flutter/material.dart';
import 'package:itoken/Pages/PCheckMnemonic.dart';
import 'package:itoken/Pages/PHome.dart';
import 'package:itoken/Pages/PImport.dart';
import 'package:itoken/Pages/PImportType.dart';
import 'package:itoken/Pages/PMain.dart';
import 'package:itoken/Pages/PShowMnemonic.dart';
import 'package:itoken/Pages/PWebView.dart';

GlobalKey<NavigatorState> navigator = new GlobalKey();

class CRouter {
  static import({
    @required ImportMold type,
  }) {
    return navigator.currentState.push(
      MaterialPageRoute(builder: (context) {
        return PImport(
          type: type,
        );
      }),
    );
  }

  static importType() {
    return navigator.currentState.push(
      MaterialPageRoute(builder: (context) {
        return PImportType();
      }),
    );
  }

  static showMnemonic({
    @required String mnemonic,
  }) {
    return navigator.currentState.push(
      MaterialPageRoute(builder: (context) {
        return PShowMnemonic(
          mnemonic: mnemonic,
        );
      }),
    );
  }

  static main() {
    return navigator.currentState.pushAndRemoveUntil(
      PageRouteBuilder(
        opaque: false,
        pageBuilder: (ctx, _, __) {
          return PMain();
        },
        transitionsBuilder: (_, Animation<double> animation, __, Widget child) {
          return FadeTransition(
            opacity: animation,
            child: child,
          );
        },
      ),
      (route) => route == null,
    );
  }

  static home() {
    return navigator.currentState.pushAndRemoveUntil(
      PageRouteBuilder(
        opaque: false,
        pageBuilder: (ctx, _, __) {
          return PHome();
        },
        transitionsBuilder: (_, Animation<double> animation, __, Widget child) {
          return FadeTransition(
            opacity: animation,
            child: child,
          );
        },
      ),
      (route) => route == null,
    );
  }

  static checkMnemonic({
    @required String mnemonic,
    @required List<String> lists,
  }) {
    return navigator.currentState.push(
      MaterialPageRoute(builder: (context) {
        return PCheckMnemonic(mnemonic: mnemonic, lists: lists);
      }),
    );
  }

  static pWebView() {
    return navigator.currentState.push(
      MaterialPageRoute(builder: (context) {
        return PWebView(
         
        );
      }),
    );
  }

  static back({data}) {
    return navigator.currentState.pop(data);
  }
}
